<template>
	<view class="fac">
		<view :class="(mult&&value.includes(item.value))||(!mult&&value==item.value)?'tag':'tag-light'" v-if="(item, i) in options" :key="i">
			{{item.label}}
		</view>
		<Loading></Loading>
	</view>
</template>

<script>
import util from '@/utils/util'
import Emitter from 'uview-plus/libs/util/emitter'

export default {
	mixins: [Emitter],
	props: {
		value: {
			type: [String, Number],
			default: ''
		},
		options: {
			type: Array,
			default: () => []
		},
		mult: {
			type: Boolean,
			default: false
		}
	},
	data() {
		return {
			val: []
		}
	},
	methods: {
		choose(v){
			if(this.mult){
				!this.val.includes(v) && this.val.push(v)
			} else {
				this.val = v
			}
			this.$emit('update:value', this.val)
			setTimeout(() => {
				// 将当前的值发送到 u-form-item 进行校验
				this.dispatch('u-form-item', 'onFieldChange', val)
			}, 40)
		}
	}
}
</script>